home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / spooler.com / SPOOLER.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1989-02-17  |  2.5 KB  |  85 lines

  1. Unit Spooler;
  2. { Brian Ebarb Power Software Company - Houston, TX (713)781-9784 }
  3. InterFace
  4. Uses Dos;
  5. function Spool(FileString: String; ThePrinter: Byte; Action: byte) : Byte;
  6. Implementation
  7. function Spool(FileString: String; ThePrinter: Byte; Action: byte) : Byte;
  8. Var
  9.    Regs : Registers;
  10.    Fname : array[1..64] of byte;
  11.    TheFile : record
  12.                    Byt  : Byte;
  13.                    Loc  : array[1..2] of Word;
  14.              end;
  15.    Tick : integer;
  16.  
  17. begin
  18. FileString := FileString+#0;
  19. FillChar(Fname, 64, #0);
  20. for Tick := 1 to Length(FileString) do Fname[Tick] := ord(FileString[Tick]);
  21. TheFile.Byt := ThePrinter - 1;
  22. TheFile.Loc[2] := Seg(Fname);
  23. TheFile.Loc[1] := Ofs(Fname);
  24. Regs.AH := $1; Regs.AL := $0; Intr($2F, Regs);
  25. if Regs.AL <> 255 then
  26.    begin
  27.         Spool := 10;       { on return, 10 = "not installed" }
  28.         Writeln('Spooler not resident!!');
  29.         exit;
  30.    end
  31. else
  32.    case Action of
  33.         1: begin      { Spool a file }
  34.            with Regs do
  35.                 begin
  36.                      AH:=$1; AL:=$1; DS:=Seg(TheFile); DX:=Ofs(TheFile);
  37.                 end;
  38.            Intr($2F, Regs);
  39.            if Regs.Flags AND FCarry = FCarry then
  40.               Spool := Regs.AX
  41.            else
  42.               Spool := 0;
  43.            end;
  44.         2: begin      {Deque a file }
  45.            with Regs do
  46.                 begin
  47.                      AH:=$1; AL:=$2; DS:=TheFile.Loc[2]; DX:=TheFile.Loc[1];
  48.                 end;
  49.            Intr($2F, Regs);
  50.            if Regs.Flags AND FCarry = FCarry then
  51.               Spool := Regs.AX
  52.            else
  53.               Spool := 0;
  54.            end;
  55.         3: begin      {Deque ALL files }
  56.            Regs.AH := $1; Regs.AL := $3;
  57.            Intr($2F, Regs);
  58.            if Regs.Flags AND FCarry = FCarry then
  59.               Spool := Regs.AX
  60.            else
  61.               Spool := 0;
  62.            end;
  63.         4: begin      { Hold queue, Get Status }
  64.            Regs.AH:=$1; Regs.AL:=$4;
  65.            Intr($2F, Regs);
  66.            if Regs.Flags AND FCarry = FCarry then
  67.               Spool := Regs.AX
  68.            else
  69.               begin
  70.                    Spool := Regs.DX;
  71.                    { put the contents of DS:SI into FILESTRING }
  72.               end;
  73.            end;
  74.         5: begin      { restart queue after function 4 }
  75.            Regs.AL := $5;
  76.            Intr($2F, Regs);
  77.            if Regs.Flags AND FCarry = FCarry then
  78.               Spool := Regs.AX
  79.            else
  80.               Spool := 0;
  81.            end;
  82.    end;
  83. end;
  84. end.
  85.